/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "FastaOptionsDlg.h"

#include <QtCore/QSettings>

#include <QtWidgets/QCheckBox>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QPushButton>

/**
**/
FastaOptionsDlg::FastaOptionsDlg( QWidget *parent ) : QDialog( parent )
{
	setWindowTitle( tr( "Information" ) );

	initLayout();
	
	QSettings	settings;

	settings.beginGroup( "Fasta" );

	m_taxonChk->setChecked( settings.value( "TaxonName", true ).toBool() );
	m_giChk->setChecked( settings.value( "GBIdentifier", true ).toBool() );
	m_accChk->setChecked( settings.value( "GBAccession", true ).toBool() );
}

/**
**/
FastaOptionsDlg::~FastaOptionsDlg()
{
}

/**
**/
void FastaOptionsDlg::accept()
{
	QSettings	settings;

	settings.beginGroup( "Fasta" );

	settings.setValue( "TaxonName", m_taxonChk->isChecked() );
	settings.setValue( "GBIdentifier", m_giChk->isChecked() );
	settings.setValue( "GBAccession", m_accChk->isChecked() );

	QDialog::accept();
}

/**
**/
bool FastaOptionsDlg::saveTaxonName() const
{
	return m_taxonChk->isChecked();
}

/**
**/
bool FastaOptionsDlg::saveGBIdentifier() const
{
	return m_giChk->isChecked();
}

/**
**/
bool FastaOptionsDlg::saveGBAccession() const
{
	return m_accChk->isChecked();
}

/**
**/
void FastaOptionsDlg::initLayout()
{
	QVBoxLayout	*layout = new QVBoxLayout;

	setLayout( layout );
	
	// defline options
	m_taxonChk = new QCheckBox( tr( "Taxon Name" ), this );
	layout->addWidget( m_taxonChk );

	m_giChk = new QCheckBox( tr( "GenBank Identifier" ), this );
	layout->addWidget( m_giChk );

	m_accChk = new QCheckBox( tr( "GenBank Accession" ), this );
	layout->addWidget( m_accChk );

	QHBoxLayout	*btnLayout = new QHBoxLayout;
	QPushButton	*btn;

	layout->addLayout( btnLayout );

	btnLayout->setMargin( 0 );
	btnLayout->addStretch( 100 );

	btn = new QPushButton( tr( "Save" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(accept()) );
	btnLayout->addWidget( btn );

	btn = new QPushButton( tr( "Cancel" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(reject()) );
	btnLayout->addWidget( btn );
}
